**Codes to replicate the results

clear
set more off

**Please provide the file path to the folder containing the downloaded heat_study_data.csv. The output files will be saved in the same folder.
global file_path "/path/to/your/folder"


import delimited "$file_path/heat_study_data.csv", clear
count

**Date and time variables

local date_var start_date end_date date_yesterday

foreach var in `date_var' {
    gen `var'_float = date(`var', "MD")  // Convert string to date
    format `var'_float %tdMonDD          
    drop `var'                        
    rename `var'_float `var'             
}

local time_var start_time end_time

foreach var in `time_var' {
    gen `var'_float = clock(`var', "hms")  
    format `var'_float %tcHH:MM:SS         
    drop `var'                           
    rename `var'_float `var'             
}

order hh_id `date_var' `time_var'

//Variable Labels

label variable hh_id "Household ID" 
label variable start_date "Start Date of Interview" 
label variable end_date "End Date of Interview" 
label variable date_yesterday "Date yesterday manually reported by enumerators" 
label variable start_time "Start time of interview" 
label variable end_time "End time of interview" 
label variable time_taken_minutes "The total time taken for survey (in minutes)" 
label variable occ_code "Occupation Code" 
label variable slept_well "Slept Well" 
label variable hours_slept "Hours Slept" 
label variable wake_time "What time did you wake up?" 
label variable whether_sick "Whether Sick" 
label variable bodytemp_inc "Please mention the health symptoms/Increase in Body Temperature" 
label variable respiration_problem "Please mention the health symptoms/Problem in Respiration" 
label variable unconscious "Please mention the health symptoms/Being Unconscious" 
label variable blur_vision "Please mention the health symptoms/Blurred Vision" 
label variable nausea "Please mention the health symptoms/Nausea, Dry throat" 
label variable body_ache "Please mention the health symptoms/Severe body ache" 
label variable tired "Please mention the health symptoms/Feeling tired" 
label variable other_symptom "Please mention the health symptoms/Any other" 
label variable tot_people_ill "How many members (inclusive of you) suffered?" 
label variable doc_visit "Visited Doctor" 
label variable doc_fees "How much did you pay as doctor fees?" 
label variable medicine_exp "What was the expenditure on medicine?" 
label variable go_to_work "Went to Work" 
label variable self_ill "What was the reason?/Illness (self)" 
label variable family_ill "What was the reason?/Illness (family)" 
label variable no_work "Didn't work- no work available" 
label variable bad_weather_heat "Didn't work due to heat" 
label variable bad_weather_rain "What was the reason?/Bad weather (rain)" 
label variable time_left "What time you left for work?" 
label variable time_return "What time you returned home?" 
label variable hours_worked "Hours Worked" 
label variable hours_rest "Hours Rested" 
label variable extra_work "Did you do any extra work, other than your normal work?" 
label variable tot_earning "Total Earnings" 
label variable morn_earning "How much money did you earn in the morning?" 
label variable evening_earning "How much money did you earn in the evening?" 
label variable extra_earning "How much did you earn from extra work?" 
label variable rm_exp "How much did you spend on buying raw materials?" 
label variable fuel_exp "How much did you spend on fuel?" 
label variable repair_exp "How much did you spend on  repairs?" 
label variable travel_exp "How much did you spend on travel?" 
label variable other_exp "Any other work related expenditure? (amount)" 
label variable exp_desc "Please provide the description of the expenditure" 
label variable tot_exp "Total Expenditure" 
label variable tot_med_exp "Total Medical Expenditure" 
label variable dow "Day of the week yesterday" 
label variable dow1 "Sunday" 
label variable dow2 "Monday" 
label variable dow3 "Tuesday" 
label variable dow4 "Wednesday" 
label variable dow5 "Thursday" 
label variable dow6 "Friday" 
label variable dow7 "Saturday" 
label variable enu_num "Enumerator ID" 
label variable workers "group(hh_id)" 
label variable mint "Min temperature" 
label variable maxt "Max temperature" 
label variable rh "Relative Humidity (%)" 
label variable avg_wbt_vidp "Wet bulb temp" 
label variable qsh "Specific Humidity (g/kg)" 
label variable avt "Mean Temperature" 
label variable why_not_worked "Reasons for not working" 
label variable not_worked "Did not work" 
label variable water "Expenditure on water" 
label variable ice "Expenditure on ice" 
label variable ice_water "Expenditure on both ice and water" 
label variable exp_ice "Expenditure on ice (amount)" 
label variable exp_water "Expenditure on water (amount)" 
label variable exp_ice_water "Expenditure on ice and water (amount)" 
label variable ihs_ice "IHS Ice Expense" 
label variable ihs_water "IHS Water Expense" 
label variable ihs_ice_water "IHS Ice and Water Expense" 
label variable ln_earning "Log Earnings" 
label variable ihs_earning "IHS Earnings" 
label variable ln_tot_exp "Log Expenditure" 
label variable ihs_tot_exp "IHS Total Expenditure" 
label variable net_earning "Net Earnings" 
label variable ihs_ne "IHS Net Earnings" 
label variable ln_tot_med_exp "Log Medical Expenditure" 
label variable ihs_med_exp "IHS Medical Expenditure" 
label variable neglne "-log(tot_earnings)" 
label variable after6june "2nd half of period dummy" 
label variable eid "eid holiday dummy" 
label variable heatwave "Heatwave" 

//Value Labels

label define yesno 0 "No" 1 "Yes"
label value slept_well whether_sick bodytemp_inc respiration_problem unconscious blur_vision nausea body_ache tired other_symptom doc_visit go_to_work self_ill family_ill no_work bad_weather_heat bad_weather_rain extra_work not_worked yesno 

label define occ_label 1 "1 Washer man/Ironing man" 2 "2 Construction worker/painter" 3 "3 Coolies" 4 "4 Manual Rickshaw driver " 5 "5 E-Rickshaw driver" 6 "6 Auto driver" 7 "7 Taxi driver (Own taxi)" 8 "8 Vendors" 9 "9 Golgapa seller" 10 "10 Lassi/juice seller" 11 "11 Ice crème seller" 12 "12 Rag picker" 13 "13 Petty traders" 14 "14 Fruits seller" 15 "15 Kabadiwala" 16 "16 Roadside barber" 17 "17 Cobbler" 18 "18 Roadside cycle/auto mechanic" 19 "19 Others"
label values occ_code occ_label

label define why_not_worked 1 "Illness (self)" 2 "Illness (family)" 3 "No work available" 4 "Didn't work due to heat" 5 "Bad weather (rain)"
label value why_not_worked why_not_worked

//Descriptive Statistics

preserve

collapse (mean) maxt mint wbt=avg_wbt_vidp gross=tot_earning ///
 (semean) se_gross=tot_earning, by(date_yesterday)
label var maxt "Max temperature"
label var mint "Min temperature"
label var wbt "Wet bulb temperature"
label var gross "Gross earnings"

twoway line maxt mint wbt date_yesterday, graphregion(color(white)) xtitle("Date", size(medium)) ///
ylabel(, angle(0) labsize(medium)) xlabel(, labsize(medium)) /// 
legend(position(6) rows(1) size(medium) order(1 "Maximum Temperature" 2  "Minimum Temperature" 3 "Wet Bulb Temperature")) ///
lpattern(dash solid shortdash)
graph export "$file_path/v3temp_gr03092024.pdf", replace

twoway line maxt mint wbt date_yesterday, graphregion(color(white)) xtitle("Date", size(medium)) ///
ylabel(, angle(0) labsize(medium)) xlabel(, labsize(medium)) /// 
legend(position(6) rows(1) size(medium) order(1 "Maximum Temperature" 2  "Minimum Temperature" 3 "Wet Bulb Temperature")) ///
lpattern(dash solid shortdash)
graph export "$file_path/v3temp_gr03092024.png", replace

gen neg_ln_e = -ln(gross)
drop if date_yesterday==td(4jun2019) | date_yesterday==td(5jun2019) | date_yesterday>td(21jun2019)

twoway (line wbt date_yesterday, yaxis(1) ytitle("Wet Bulb Temperature", axis(1)) ylabel(, angle(0) axis(1) labsize(medium)) lpattern(dash)) ///  
(line neg_ln_e date_yesterday, yaxis(2)  ytitle("Negative log earnings", axis(2)) ylabel(, angle(0) axis(2) labsize(medium)) lpattern(solid)), ///
xtitle("Date", size(medium)) graphregion(color(white)) /// 
legend(position(6) rows(1) size(medium) order(1 "Wet Bulb Temperature" 2 "Negative of Log (earnings)")) xlabel(, labsize(medium))
graph export "$file_path/v3earnings_wbt03092024.pdf", replace

twoway (line wbt date_yesterday, yaxis(1) ytitle("Wet Bulb Temperature", axis(1)) ylabel(, angle(0) axis(1) labsize(medium)) lpattern(dash)) ///  
(line neg_ln_e date_yesterday, yaxis(2)  ytitle("Negative log earnings", axis(2)) ylabel(, angle(0) axis(2) labsize(medium)) lpattern(solid)), ///
xtitle("Date", size(medium)) graphregion(color(white)) /// 
legend(position(6) rows(1) size(medium) order(1 "Wet Bulb Temperature" 2 "Negative of Log (earnings)")) xlabel(, labsize(medium))
graph export "$file_path/v3earnings_wbt03092024.png", replace

restore

estpost tabstat mint maxt avt avg_wbt_vidp rh tot_earning net_earning tot_exp tot_med_exp whether_sick doc_visit slept_well not_worked hours_slept hours_worked bad_weather_heat no_work exp_ice exp_water exp_ice_water, ///
statistics (mean min max sd) columns(statistics)
esttab using "$file_path/v3summary03_09_2024.tex", replace label /// 
cells("mean(fmt(2)) min (fmt(0)) max (fmt(0)) sd (fmt(2))") nonumber noobs title("Summary Statistics") collabels ("Mean" "Minimum" "Maximum" "SD") 

***If the tex file shows compilation error, add:
/*
\documentclass[]{article}
\setlength{\pdfpagewidth}{8.5in} \setlength{\pdfpageheight}{11in}
\begin{document}
\end{document}
*/

*please add (\%) as sign of percent after "relative humidity" in the tex file since esttab does not account for tex symbols.

************************REGRESSIONS****************************************

*net install cleanplots, from("https://tdmize.github.io/data/cleanplots")
set scheme cleanplots
graph set window fontface "Arial Narrow"

xtset workers date_yesterday


********Table A.2: Gross Earnings regressions from Equation 1************
************** IHS Total earnings **************** 

xtreg ihs_earning maxt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_earning_dow0
predict xbhat_ihs, xb
predict double ehat, residual 
egen duan = mean(exp(ehat))
margins, eydx(maxt) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_earnings_maxt_mint_separate.tex", replace  label addstat(AIC, `AICq') title(Regression-IHS Total Earnings)

xtreg ihs_earning mint rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_earning_dow1
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(mint) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_earnings_maxt_mint_separate.tex", append  label addstat(AIC, `AICq') title(Regression-IHS Total Earnings)

xtreg ihs_earning avt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_earning_dow2
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(avt) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_earnings_maxt_mint_separate.tex",  append label addstat(AIC, `AICq')

xtreg ihs_earning avg_wbt_vidp eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_earning_dow3
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(avg_wbt_vidp) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_earnings_maxt_mint_separate.tex", append label addstat(AIC, `AICq')


************Table A.3: Net Earnings regressions***************
***************** IHS net earnings ****************************


xtreg ihs_ne maxt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_ne_dow0
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(maxt) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_net_earning_maxt_mint_separate.tex", replace label addstat(AIC, `AICq') ctitle(IHS Net, Earnings) title(Regression-IHS Net Earnings)

xtreg ihs_ne mint rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_ne_dow1
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(mint) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_net_earning_maxt_mint_separate.tex", append label addstat(AIC, `AICq') ctitle(IHS Net, Earnings) 

xtreg ihs_ne avt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_ne_dow2
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(avt) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_net_earning_maxt_mint_separate.tex",  append label addstat(AIC, `AICq') ctitle(IHS Net, Earnings)

xtreg ihs_ne avg_wbt_vidp eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_ne_dow3
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(avg_wbt_vidp) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_net_earning_maxt_mint_separate.tex", append label addstat(AIC, `AICq') ctitle(IHS Net, Earnings)


*********Table A.4: Total Expenditure regressions*************
************ IHS total expenditure ******************


xtreg ihs_tot_exp maxt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_tot_exp_dow0
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(maxt) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_expenditure_maxt_mint_separate.tex", replace ctitle(IHS Total, Expenditure) label addstat(AIC, `AICq') title(Regression-IHS Total Expenditure)

xtreg ihs_tot_exp mint rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_tot_exp_dow1
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(mint) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_expenditure_maxt_mint_separate.tex", append ctitle(IHS Total, Expenditure) label addstat(AIC, `AICq') 

xtreg ihs_tot_exp avt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_tot_exp_dow2
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(avt) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_expenditure_maxt_mint_separate.tex", append ctitle(IHS Total, Expenditure) label addstat(AIC, `AICq')

xtreg ihs_tot_exp avg_wbt_vidp eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_tot_exp_dow3
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(avg_wbt_vidp) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_expenditure_maxt_mint_separate.tex", append ctitle(IHS Total, Expenditure) label addstat(AIC, `AICq')

******** Figure 3 -- coeff plot IHS Total Earnings, Net Earnings, and Total Expenditure ****************

coefplot (ihs_earning_dow0 ihs_earning_dow1 ihs_earning_dow2 ihs_earning_dow3, label("IHS Total Earnings") drop(_cons rh eid dow2 dow3 dow4 dow5 dow6 dow7) msymbol(Oh)) ///
(ihs_ne_dow0 ihs_ne_dow1 ihs_ne_dow2 ihs_ne_dow3, label("IHS Net Earnings") drop(_cons rh eid dow2 dow3 dow4 dow5 dow6 dow7) msymbol(Dh)) ///
(ihs_tot_exp_dow0 ihs_tot_exp_dow1 ihs_tot_exp_dow2 ihs_tot_exp_dow3,  label("IHS Expenditure") drop(_cons rh eid dow2 dow3 dow4 dow5 dow6 dow7) msymbol(Sh)) ///
, vertical yline(0, lpattern(solid) lwidth(medthick))  graphregion(color(white)) ///
title(`"{fontface Arial Bold: Marginal Effects of Heat Measures}"' `"{fontface Arial Bold: on IHS Total Earnings, Net Earnings and IHS Work Expenditure}"', size(medium)) ///
subtitle(" ") ///
xlabel(1 `" "Maximum" "Temperature" "' 2 `" "Minimum" "Temperature" "' 3 `" "Mean" "Temperature" "' 4 `" "Wet Bulb" "Temperature" "') xlabel(, labsize(medium)) ///
ylabel(-0.25(0.03)0.08, angle(0) labsize(medium) glpattern(shortdash) glwidth(thin)) yscale(range(-0.25(0.03)0.08)) /// 
legend(position(6) rows(1) size(medium)) 

graph export "$file_path/v4ihs_earning_expenditure_coef_dow_maxt_mint_separate.pdf",  replace
graph export "$file_path/v4ihs_earning_expenditure_coef_dow_maxt_mint_separate.png", replace

**********************Table A.5: Net earnings regressions controlling for specific humidity

xtreg ihs_ne avt qsh eid dow2-dow7, fe vce(cluster workers) 
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_ne_dow0
outreg2 using "$file_path/v4ihs_net_earning_avt_qsh_rh_noh.tex", replace label addstat(AIC, `AICq') ctitle(IHS Net, Earnings) title(Regression-IHS Net Earnings)

xtreg ihs_ne avt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icr = r(S)
local AICr: display %4.1f es_icr[1,5]
estimates store ihs_ne_dow0
outreg2 using "$file_path/v4ihs_net_earning_avt_qsh_rh_noh.tex", append label addstat(AIC, `AICr') ctitle(IHS Net, Earnings) 

xtreg ihs_ne avt eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icn = r(S)
local AICn: display %4.1f es_icn[1,5]
estimates store ihs_ne_dow0
outreg2 using "$file_path/v4ihs_net_earning_avt_qsh_rh_noh.tex", append label addstat(AIC, `AICn') ctitle(IHS Net, Earnings) 

xtreg ihs_ne avg_wbt eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icw = r(S)
local AICw: display %4.1f es_icw[1,5]
estimates store ihs_ne_dow0
outreg2 using "$file_path/v4ihs_net_earning_avt_qsh_rh_noh.tex", append label addstat(AIC, `AICw') ctitle(IHS Net, Earnings) 

******************Table A.6: Regression-Probability of Not Working

xtreg not_worked maxt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store not_worked_dow0
outreg2 using "$file_path/v4not_worked_maxt_mint_separate.tex", replace  label addstat(AIC, `AICq') ctitle(Didn't work) title(Regression-Probability of Not Working)
xtreg not_worked mint rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store not_worked_dow1
outreg2 using "$file_path/v4not_worked_maxt_mint_separate.tex", append  label addstat(AIC, `AICq') ctitle(Didn't work) 
xtreg not_worked avt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store not_worked_dow2
outreg2 using "$file_path/v4not_worked_maxt_mint_separate", append  label addstat(AIC, `AICq') ctitle(Didn't work) 
xtreg not_worked avg_wbt_vidp eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store not_worked_dow3
outreg2 using "$file_path/v4not_worked_maxt_mint_separate.tex", append label addstat(AIC, `AICq') ctitle(Didn't work) 

************Table A.7: Regression-Probability of Not Working due to heat


xtreg bad_weather_heat maxt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store bad_weather_heat_dow0
outreg2 using "$file_path/v4bad_weather_heat_maxt_mint_separate.tex", replace  label addstat(AIC, `AICq') ctitle(Too hot) title(Regression-Probability of Not Working due to heat)

xtreg bad_weather_heat mint rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store bad_weather_heat_dow1
outreg2 using "$file_path/v4bad_weather_heat_maxt_mint_separate.tex", append  label addstat(AIC, `AICq') ctitle(Too hot) 

xtreg bad_weather_heat avt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store bad_weather_heat_dow2
outreg2 using "$file_path/v4bad_weather_heat_maxt_mint_separate.tex", append  label addstat(AIC, `AICq') ctitle(Too hot) 

xtreg bad_weather_heat avg_wbt_vidp eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store bad_weather_heat_dow3
outreg2 using "$file_path/v4bad_weather_heat_maxt_mint_separate.tex", append label addstat(AIC, `AICq') ctitle(Too hot) 


************Table A.8: Regression-Probability of No Work Available

xtreg no_work maxt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store no_work_dow0
outreg2 using "$file_path/v4no_work_maxt_mint_separate.tex", replace  label addstat(AIC, `AICq') ctitle(No Work, Available) title(Regression-Probability of No Work available)

xtreg no_work mint rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store no_work_dow1
outreg2 using "$file_path/v4no_work_maxt_mint_separate.tex", append  label addstat(AIC, `AICq') ctitle(No Work, Available) 

xtreg no_work avt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store no_work_dow2
outreg2 using "$file_path/v4no_work_maxt_mint_separate.tex", append  label addstat(AIC, `AICq') ctitle(No Work, Available) 

xtreg no_work avg_wbt_vidp eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store no_work_dow3
outreg2 using "$file_path/v4no_work_maxt_mint_separate.tex", append label addstat(AIC, `AICq') ctitle(No Work, Available) 

******Figure 4 Marginal Effects of Heat Measures on the Probability of not working, not working due to heat, no work to be had

coefplot (not_worked_dow0 not_worked_dow1 not_worked_dow2 not_worked_dow3, label("Not Worked") drop(_cons rh eid dow2 dow3 dow4 dow5 dow6 dow7) msymbol(Oh)) ///
(bad_weather_heat_dow0 bad_weather_heat_dow1 bad_weather_heat_dow2 bad_weather_heat_dow3, label("Due to Heat") drop(_cons rh eid dow2 dow3 dow4 dow5 dow6 dow7) msymbol(Dh)) ///
(no_work_dow0 no_work_dow1 no_work_dow2 no_work_dow3, label("Work not available") drop(_cons rh eid dow2 dow3 dow4 dow5 dow6 dow7) msymbol(Sh)) ///
, vertical yline(0, lpattern(solid) lwidth(medthick))  graphregion(color(white)) ///
title(`"{fontface Arial Bold: Marginal Effects of Heat Measures on the}"' `"{fontface Arial Bold: Probability of not working, not working due to heat, no work to be had}"', size(medium)) ///
subtitle(" ") ///
xlabel(1 `" "Maximum" "Temperature" "' 2 `" "Minimum" "Temperature" "' 3 `" "Mean" "Temperature" "' 4 `" "Wet Bulb" "Temperature" "') xlabel(, labsize(medium)) ///
ylabel(-0.02(0.01)0.09, angle(0) labsize(medium) glpattern(shortdash) glwidth(thin)) yscale(range(-0.02(0.01)0.09)) /// 
legend(position(6) rows(1) size(medium))

graph export "$file_path/v4no_work_coef_maxt_mint_separate.pdf", replace
graph export "$file_path/v4no_work_coef_maxt_mint_separate.png", replace


**********Table A.9: Regression- Whether Sick

xtreg whether_sick maxt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store whether_sick_dow0
outreg2 using "$file_path/v4whether_sick_maxt_mint_separate.tex", replace label addstat(AIC, `AICq') title(Regression- Whether Sick)

xtreg whether_sick mint rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store whether_sick_dow1
outreg2 using "$file_path/v4whether_sick_maxt_mint_separate.tex", append label addstat(AIC, `AICq') 

xtreg whether_sick avt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store whether_sick_dow2
outreg2 using "$file_path/v4whether_sick_maxt_mint_separate.tex", append label addstat(AIC, `AICq')

xtreg whether_sick avg_wbt_vidp eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store whether_sick_dow3
outreg2 using "$file_path/v4whether_sick_maxt_mint_separate.tex", append label addstat(AIC, `AICq')


**********Table A.10: Regression- Visited Doctor

xtreg doc_visit maxt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store doc_visit_dow0
outreg2 using "$file_path/v4doc_visit_maxt_mint_separate.tex", replace label addstat(AIC, `AICq') title(Regression- Visited Doctor)

xtreg doc_visit mint rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store doc_visit_dow1
outreg2 using "$file_path/v4doc_visit_maxt_mint_separate.tex", append label addstat(AIC, `AICq') 

xtreg doc_visit avt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store doc_visit_dow2
outreg2 using "$file_path/v4doc_visit_maxt_mint_separate.tex", append label addstat(AIC, `AICq')

xtreg doc_visit avg_wbt_vidp eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store doc_visit_dow3
outreg2 using "$file_path/v4doc_visit_maxt_mint_separate.tex", append label addstat(AIC, `AICq')


******Table A.11: Regression- Slept Well


xtreg slept_well maxt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store slept_well_dow0
outreg2 using "$file_path/v4slept_well_maxt_mint_separate.tex", replace label addstat(AIC, `AICq') title(Regression-Slept Well)

xtreg slept_well mint rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store slept_well_dow1
outreg2 using "$file_path/v4slept_well_maxt_mint_separate.tex", append label addstat(AIC, `AICq') 

xtreg slept_well avt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store slept_well_dow2
outreg2 using "$file_path/v4slept_well_maxt_mint_separate.tex", append label addstat(AIC, `AICq')

xtreg slept_well avg_wbt_vidp eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store slept_well_dow3
outreg2 using "$file_path/v4slept_well_maxt_mint_separate.tex", append label addstat(AIC, `AICq')

******** Table A.12: Regression- Went to Work

xtreg go_to_work maxt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store go_to_work_dow0
outreg2 using "$file_path/v4go_to_work_maxt_mint_separate.tex", replace label addstat(AIC, `AICq') title(Regression-Went to Work)

xtreg go_to_work mint rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store go_to_work_dow1
outreg2 using "$file_path/v4go_to_work_maxt_mint_separate.tex", append label addstat(AIC, `AICq')
 
xtreg go_to_work avt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store go_to_work_dow2
outreg2 using "$file_path/v4go_to_work_maxt_mint_separate.tex", append label addstat(AIC, `AICq')

xtreg go_to_work avg_wbt_vidp eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store go_to_work_dow3
outreg2 using "$file_path/v4go_to_work_maxt_mint_separate.tex", append label addstat(AIC, `AICq')


***********Figure 5 Marginal Effects of Heat Measures on Self-reported Health Indicators ***************

coefplot (whether_sick_dow0 whether_sick_dow1 whether_sick_dow2 whether_sick_dow3, label("Whether Sick") drop(_cons rh eid dow2 dow3 dow4 dow5 dow6 dow7) msymbol(Oh)) ///
(doc_visit_dow0 doc_visit_dow1 doc_visit_dow2 doc_visit_dow3, label("Visited Doctor") drop (_cons rh eid dow2 dow3 dow4 dow5 dow6 dow7) msymbol(Dh)) ///
(slept_well_dow0 slept_well_dow1 slept_well_dow2 slept_well_dow3, label("Slept Well") drop(_cons rh eid dow2 dow3 dow4 dow5 dow6 dow7) msymbol(Sh)) ///
(go_to_work_dow0 go_to_work_dow1 go_to_work_dow2 go_to_work_dow3, label("Went to Work") drop (_cons rh eid dow2 dow3 dow4 dow5 dow6 dow7) msymbol(Th)) ///
, vertical yline(0 , lpattern(solid) lwidth(medthick))  graphregion(color(white)) ///
title(`"{fontface Arial Bold: Marginal Effects of Heat Measures}"' `"{fontface Arial Bold: on Self-reported Health Indicators}"', size(medium)) ///
subtitle(" ") ///
xlabel(1 `" "Maximum" "Temperature" "' 2 `" "Minimum" "Temperature" "' 3 `" "Mean" "Temperature" "' 4 `" "Wet Bulb" "Temperature" "') xlabel(, labsize(medium)) /// 
ylabel(0.07(0.01)-0.03, angle(0) labsize(medium) glpattern(shortdash)) legend(position(6) rows(1) size(medium)) yscale(range(0.07(0.01)-0.03))


graph export "$file_path/v4sick_coeff_maxt_mint_separate.pdf", replace
graph export "$file_path/v4sick_coeff_maxt_mint_separate.png", replace


********Table A.13: Regression- Hours Slept

xtreg hours_slept maxt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store hours_slept_dow0
outreg2 using "$file_path/v4hours_slept_maxt_mint_separate.tex", replace label addstat(AIC, `AICq') title(Regression- Hours Slept)
xtreg hours_slept mint rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store hours_slept_dow1
outreg2 using "$file_path/v4hours_slept_maxt_mint_separate.tex", append label addstat(AIC, `AICq') 
xtreg hours_slept avt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store hours_slept_dow2
outreg2 using "$file_path/v4hours_slept_maxt_mint_separate.tex", append label addstat(AIC, `AICq')
xtreg hours_slept avg_wbt_vidp eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store hours_slept_dow3
outreg2 using "$file_path/v4hours_slept_maxt_mint_separate.tex", append label addstat(AIC, `AICq')

********Table A.13: Regression- Hours Worked

xtreg hours_worked maxt rh eid dow2-dow7 if go_to_work==1, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store hours_worked_dow0
outreg2 using "$file_path/v4hours_worked_maxt_mint_separate.tex", replace label addstat(AIC, `AICq') title(Regression-Hours Worked)
xtreg hours_worked mint rh eid dow2-dow7 if go_to_work==1, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store hours_worked_dow1
outreg2 using "$file_path/v4hours_worked_maxt_mint_separate.tex", append label addstat(AIC, `AICq') 
xtreg hours_worked avt rh eid dow2-dow7 if go_to_work==1, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store hours_worked_dow2
outreg2 using "$file_path/v4hours_worked_maxt_mint_separate.tex", append label addstat(AIC, `AICq')
xtreg hours_worked avg_wbt_vidp eid dow2-dow7 if go_to_work==1, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store hours_worked_dow3
outreg2 using "$file_path/v4hours_worked_maxt_mint_separate.tex", append label addstat(AIC, `AICq')

************Figure 6********************************
***********Coefficent plot- Hours slept, worked***********
coefplot (hours_slept_dow0 hours_slept_dow1 hours_slept_dow2 hours_slept_dow3, label("Hours Slept") drop (_cons rh eid dow2 dow3 dow4 dow5 dow6 dow7) msymbol(Oh)) ///
(hours_worked_dow0 hours_worked_dow1 hours_worked_dow2 hours_worked_dow3, label("Hours Worked") drop (_cons rh eid dow2 dow3 dow4 dow5 dow6 dow7) msymbol(Sh)) ///
, vertical yline(0, lpattern(solid) lwidth(medthick))  graphregion(color(white)) ///
title(`"{fontface Arial Bold: Marginal Effects of Heat Measures on the number of}"' `"{fontface Arial Bold: hours slept and worked}"', size(medium)) ///
subtitle(" ") ///
xlabel(1 `" "Maximum" "Temperature" "' 2 `" "Minimum" "Temperature" "' 3 `" "Mean" "Temperature" "' 4 `" "Wet Bulb" "Temperature" "') xlabel(, labsize(medium)) /// 
ylabel(0.04(0.04)-0.25,angle(0) glpattern(shortdash) labsize(medium)) legend(position(6) rows(1) size(medium)) yscale(range(0.04(0.04)-0.25))

graph export "$file_path/v4sleep_coeff_maxt_mint_separate.pdf", replace
graph export "$file_path/v4sleep_coeff_maxt_mint_separate.png", replace


******Table A.15: Regression-IHS Medical Expenditure

xtreg ihs_med_exp maxt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_med_exp_dow0
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(maxt) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs-med-expenditure_maxt_mint_separate.tex", replace  label addstat(AIC, `AICq') ctitle(IHS Medical, Expenditure) title(Regression-IHS Medical Expenditure)

xtreg ihs_med_exp mint rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_med_exp_dow1
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(mint) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs-med-expenditure_maxt_mint_separate.tex", append  label addstat(AIC, `AICq') ctitle(IHS Medical, Expenditure)

xtreg ihs_med_exp avt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_med_exp_dow2
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(avt) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs-med-expenditure_maxt_mint_separate.tex", append  label addstat(AIC, `AICq') ctitle(IHS Medical, Expenditure)

xtreg ihs_med_exp avg_wbt_vidp eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_med_exp_dow3
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(avg_wbt_vidp) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs-med-expenditure_maxt_mint_separate.tex", append label addstat(AIC, `AICq') ctitle(IHS Medical, Expenditure)

**************Table A.16: Regression-IHS Ice

xtreg ihs_ice maxt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_ice_dow0
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(maxt) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
estimates store ihs_ice_dow0_margins
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_ice_maxt_mint_separate.tex", replace ctitle("IHS Ice") label addstat(AIC, `AICq') title(Regression-IHS Ice)

xtreg ihs_ice mint rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_ice_dow1
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(mint) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
estimates store ihs_ice_dow1_margins
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_ice_maxt_mint_separate.tex", append ctitle("IHS Ice") label addstat(AIC, `AICq') 

xtreg ihs_ice avt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_ice_dow2
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(avt) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
estimates store ihs_ice_dow2_margins
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_ice_maxt_mint_separate.tex", append ctitle("IHS Ice") label addstat(AIC, `AICq') 

xtreg ihs_ice avg_wbt_vidp eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_ice_dow3
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(avg_wbt_vidp) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
estimates store ihs_ice_dow3_margins
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_ice_maxt_mint_separate.tex", append ctitle("IHS Ice") label addstat(AIC, `AICq') 

********************Table A.16: Regression-IHS Water

xtreg ihs_water maxt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_water_dow0
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(maxt) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
estimates store ihs_water_dow0_margins
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_water_maxt_mint_separate.tex", replace ctitle("IHS Water") label addstat(AIC, `AICq') title(Regression-IHS Water)

xtreg ihs_water mint rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_water_dow1
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(mint) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
estimates store ihs_water_dow1_margins
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_water_maxt_mint_separate.tex", append ctitle("IHS Water") label addstat(AIC, `AICq') 

xtreg ihs_water avt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_water_dow2
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(avt) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
estimates store ihs_water_dow2_margins
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_water_maxt_mint_separate", append ctitle("IHS Water") label addstat(AIC, `AICq') 

xtreg ihs_water avg_wbt_vidp eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_water_dow3
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(avg_wbt_vidp) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
estimates store ihs_water_dow3_margins
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_water_maxt_mint_separate.tex", append ctitle("IHS Water") label addstat(AIC, `AICq') 

*************Table A.16: Regression-IHS Ice and Water

xtreg ihs_ice_water maxt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_ice_water_dow0
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(maxt) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
estimates store ihs_ice_water_dow0_margins
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_ice_water_maxt_mint_separate.tex", replace ctitle("Ice and Water") label addstat(AIC, `AICq') title(Regression-IHS Ice and Water)

xtreg ihs_ice_water mint rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_ice_water_dow1
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(mint) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
estimates store ihs_ice_water_dow1_margins
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_ice_water_maxt_mint_separate.tex", append ctitle("Ice and Water") label addstat(AIC, `AICq') title(Regression-IHS Ice and Water)

xtreg ihs_ice_water avt rh eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_ice_water_dow2
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(avt) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
estimates store ihs_ice_water_dow2_margins
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_ice_water_maxt_mint_separate.tex", append ctitle("Ice and Water") label addstat(AIC, `AICq') title(Regression-IHS Ice and Water)

xtreg ihs_ice_water avg_wbt_vidp eid dow2-dow7, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store ihs_ice_water_dow3
predict xbhat_ihs, xb
predict double ehat, residual
egen duan = mean(exp(ehat))
margins, eydx(avg_wbt_vidp) expression(.5*(exp(xb())*duan - (1/(exp(xb())*duan))))
estimates store ihs_ice_water_dow3_margins
drop xbhat_ihs ehat duan
outreg2 using "$file_path/v4ihs_ice_water_maxt_mint_separate.tex", append ctitle("Ice and Water") label addstat(AIC, `AICq') title(Regression-IHS Ice and Water)

**********Figure 7 Marginal Effects of Heat Measures on IHS Medical, Ice and Water Expenditure

coefplot (ihs_med_exp_dow0 ihs_med_exp_dow1 ihs_med_exp_dow2 ihs_med_exp_dow3, label("IHS Medical Expenditure") drop(_cons rh eid dow2 dow3 dow4 dow5 dow6 dow7) msymbol(X)) ///
(ihs_ice_dow0 ihs_ice_dow1 ihs_ice_dow2 ihs_ice_dow3, label("IHS Ice Only") drop(_cons rh eid dow2 dow3 dow4 dow5 dow6 dow7) msymbol(Oh)) ///
(ihs_water_dow0 ihs_water_dow1 ihs_water_dow2 ihs_water_dow3, label("IHS Water Only") drop(_cons rh eid dow2 dow3 dow4 dow5 dow6 dow7) msymbol(Dh)) ///
(ihs_ice_water_dow0 ihs_ice_water_dow1 ihs_ice_water_dow2 ihs_ice_water_dow3,  label("IHS Ice & Water") drop(_cons rh eid dow2 dow3 dow4 dow5 dow6 dow7) msymbol(Sh)) ///
, vertical yline(0, lpattern(solid) lwidth(medthick))  graphregion(color(white)) ///
title(`"{fontface Arial Bold: Marginal Effects of Heat Measures on}"' `"{fontface Arial Bold: IHS Medical, Ice and Water Expenditure}"', size(medium)) ///
subtitle(" ") ///
xlabel(1 `" "Maximum" "Temperature" "' 2 `" "Minimum" "Temperature" "' 3 `" "Mean" "Temperature" "' 4 `" "Wet Bulb" "Temperature" "') xlabel(, labsize(medium)) ///
ylabel(0.0(0.02)0.18, angle(0) labsize(medium) glpattern(shortdash) glwidth(thin)) yscale(range(0.0(0.02)0.18)) /// 
legend(position(6) rows(1) size(medium))

graph export "$file_path/v4med_ice_water_maxt_mint_separate.pdf", replace
graph export "$file_path/v4med_ice_water_maxt_mint_separate.png", replace

tab occ_code

*generating occupation variable by likly to decrease demand due to heat
gen occ_demand =1 if occ_code==4 | occ_code==5 | occ_code==9 | occ_code==13 | occ_code==16 | occ_code==17 
replace occ_demand = 99 if occ_code == 6| occ_code==7 | occ_code== 18 | occ_code==19

replace occ_demand = 0 if occ_code<=3 | occ_code==8 | (occ_code >=10 & occ_code <=12) | occ_code==14 | occ_code==15

*labeling occ_demand
label define demand 0 "Unlikely to decrease when hot" 1 "Likely to decrease when hot" 99 "Unsure"
label values occ_demand demand

xtset workers date_yesterday

*************Table A.19: Regression-Probability of Not Working for workers facing decrease in demand

*** dec in demand

xtreg not_worked maxt rh eid dow2-dow7 if occ_demand ==1, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store not_worked_dow0
outreg2 using "$file_path/not_worked_dec_demand.tex", replace  label addstat(AIC, `AICq') ctitle(Didn't work) title(Regression-Probability of Not Working for workers facing decrease in demand)

xtreg not_worked mint rh eid dow2-dow7 if occ_demand ==1, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store not_worked_dow1
outreg2 using "$file_path/not_worked_dec_demand.tex", append  label addstat(AIC, `AICq') ctitle(Didn't work) 

xtreg not_worked avt rh eid dow2-dow7 if occ_demand ==1, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store not_worked_dow2
outreg2 using "$file_path/not_worked_dec_demand.tex", append  label addstat(AIC, `AICq') ctitle(Didn't work) 

xtreg not_worked avg_wbt_vidp eid dow2-dow7 if occ_demand ==1, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store not_worked_dow3
outreg2 using "$file_path/not_worked_dec_demand.tex", append label addstat(AIC, `AICq') ctitle(Didn't work)


***********Table A.20: Regression-Probability of Not Working for workers facing no decrease in demand
***no dec in demand

xtreg not_worked maxt rh eid dow2-dow7 if occ_demand ==0, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store not_worked_dow0
outreg2 using "$file_path/not_worked_no_dec_demand.tex", replace  label addstat(AIC, `AICq') ctitle(Didn't work) title(Regression-Probability of Not Working for workers facing no decrease in demand)

xtreg not_worked mint rh eid dow2-dow7 if occ_demand ==0, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store not_worked_dow1
outreg2 using "$file_path/not_worked_no_dec_demand.tex", append  label addstat(AIC, `AICq') ctitle(Didn't work) 

xtreg not_worked avt rh eid dow2-dow7 if occ_demand ==0, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store not_worked_dow2
outreg2 using "$file_path/not_worked_no_dec_demand.tex", append  label addstat(AIC, `AICq') ctitle(Didn't work) 

xtreg not_worked avg_wbt_vidp eid dow2-dow7 if occ_demand ==0, fe vce(cluster workers)
estat ic
mat es_icq = r(S)
local AICq: display %4.1f es_icq[1,5]
estimates store not_worked_dow3
outreg2 using "$file_path/not_worked_no_dec_demand.tex", append label addstat(AIC, `AICq') ctitle(Didn't work) 

********Table A.21: Some effects of heatwaves 

xtreg ihs_ne heatwave rh eid dow2-dow7, fe vce(cluster workers) 
local pc_change_ne = 100*(exp(_b[heatwave])-1)
display "% change in outcome = " `pc_change_ne'
outreg2 using "$file_path/heatwave-results.tex", ///
replace label ctitle(IHS Net Earnings) addnote("The % change in net earnings due to a heatwave is 100*[exp(coeff of heatwave) - 1]")

xtreg go_to_work heatwave rh eid dow2-dow7, fe vce(cluster workers) 
outreg2 using "$file_path/heatwave-results.tex", ///
append label ctitle(Go To Work) 

xtreg whether_sick heatwave rh eid dow2-dow7, fe vce(cluster workers) 
outreg2 using "$file_path/heatwave-results.tex", ///
append label ctitle(Whether Sick) 

